﻿using KingerRobot.MexicoSailunWMS.Spi;

namespace KingerRobot.MexicoSailunWMS.SpiService;
internal interface IProdProduct
{
    /// <summary>
    /// 获取所有产品
    /// </summary>
    /// <returns></returns>
    List<POProdProduct> GetOProdProducts();
    /// <summary>
    /// 根据胎号获取成型信息
    /// </summary>
    /// <param name="code"></param>
    /// <returns></returns>
    List<POProdProduct> GetProductListByCode(string code);

    List<ProductInfo> GetProductListByCodeV1(string code,string orderByName, string orderByType);
    /// <summary>
    /// 创建产品
    /// </summary>
    /// <param name="prodProductBean"></param>
    /// <returns>产品信息</returns>
    POProdProduct CreateProduct(ProdProductBean prodProductBean);

    /// <summary>
    /// 删除产品
    /// </summary>
    /// <param name="productCode"></param>
    /// <returns></returns>
    POProdProduct DeleteProduct(string productCode);
    /// <summary>
    /// 创建产品及相关绑定数据
    /// </summary>
    /// <param name="productBindingInfoBean"></param>
    /// <returns>产品绑定信息（prod_product,prod_sku_product,prod_sku）</returns>
    ProdProductBindingBean CreateProductBindingInfo(ProductBindingInfoBean productBindingInfoBean);
    /// <summary>
    /// 通过产品条码获取产品信息
    /// </summary>
    /// <param name="code">产品条码</param>
    /// <returns>产品信息</returns>
    POProdProduct GetProductByCode(string code);

    /// <summary>
    /// 通过产品条码获取产品是否存在
    /// </summary>
    /// <param name="code">产品条码</param>
    /// <returns>true:存在；false:不存在</returns>
    bool HasProductByCode(string code);

    /// <summary>
    /// 通过产品条码获取产品绑定信息
    /// </summary>
    /// <param name="code">产品条码</param>
    /// <returns>产品绑定信息（prod_product,prod_sku_product,prod_sku）</returns>
    ProdProductBindingBean GetProductBindingInfoByCode(string code);
    /// <summary>
    /// 通过产品条码获取所有产品绑定信息
    /// </summary>
    /// <param name="codes"></param>
    /// <returns></returns>
    List<ProdProductBindingBean> GetProductBindingInfoByCodes(List<string> codes);
    /// <summary>
    /// 通过产品条码获取SkuId
    /// </summary>
    /// <param name="code">产品条码</param>
    /// <returns>SkuId</returns>
    long GetSkuIdByCode(string code);

    /// <summary>
    /// 通过 SKUID 获取产品编号
    /// </summary>
    /// <param name="skuId"></param>
    /// <returns></returns>
    string GetCodeBySkuId(long skuId);
    /// <summary>
    /// 获取产品所有信息
    /// </summary>
    /// <param name="skuId"></param>
    /// <returns></returns>
    ProdProductBindingBean GetProductBindingInfoBySkuId(long skuId);



}

internal class ProdProductBindingBean
{
    public POMesGreenTireBuilding POMesGreenTireBuilding { get; set; }
    public POProdProduct POProdProduct { get; set; }
    public POProdSku POProdSku { get; set; }
    public POProdSkuProduct POProdSkuProduct { get; set; }
    public POProdMaterial POProdMaterial { get; set; }
}

internal class ProdProductBean
{
    public string ProductCode { get; set; }
    public long MdEquipId { get; set; }
    public long MaterialId { get; set; }
    public string ProductBatch { get; set; }
    public DateTime? MdTime { get; set; }
    public string GtStatus { get; set; }
    public int? TireLock { get; set; }

    public string MdEquipCode { get; set; }
    /// <summary>
    /// 质量：1:不合格0:合格
    /// </summary>
    public int? QuailtyStatus { get; set; }

}

internal class ProductBindingInfoBean
{
    /// <summary>
    /// 产品编号
    /// </summary>
    public string ProductCode { get; set; }
    /// <summary>
    /// 产品批次
    /// </summary>
    public string ProductBatch { get; set; }
    /// <summary>
    /// 物料编号
    /// </summary>
    public string MaterialCode { get; set; }
    /// <summary>
    /// 物料名
    /// </summary>
    public string MaterialName { get; set; }
    /// <summary>
    /// 有限出库
    /// </summary>
    public string Priooutyn { get; set; }
    /// <summary>
    /// 生产时间
    /// </summary>
    public DateTime? MdTime { get; set; }
    /// <summary>
    /// 成型机
    /// </summary>
    public string MdEquipCode { get; set; }
    /// <summary>
    /// W-hold,N-normal,B-Bad,G-Bad Weight,E-Expire
    /// </summary>
    public string GtStatus { get; set; }

    /// <summary>
    /// 胎胚锁定 0:解锁 1:锁定
    /// </summary>
    public int? TireLock { get; set; }

    /// <summary>
    /// 质量 0:合格 1:不合格
    /// </summary>
    public int? ProductQuality { get; set; }

    /// <summary>
    /// 生产时间
    /// </summary>
    public DateTime? ProductTime { get; set; }
    /// <summary>
    /// 成型机code(mes传过来的)
    /// </summary>
    public string ProductEquip { get; set; }

    /// <summary>
    /// 质量 0:合格 1:不合格
    /// </summary>
    public int? QualityStatus { get; set; }

}